<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    //定义一个person
    let Person =function () {//等效创建person.java 里面什么都不写
    }
    //实例化对象
    let p =new Person();
    //在js中可以动态的给实例化对象添加属性和方法
    p.name ="张三";
    p.age =18;
    p.run=function () {
        alert(this.name);
    }
    //调用对象中的方法
    //p.run();
    //直接实例化对象
    let hero ={
        name:"孙悟空",
        age:500,
        run:function () {
            alert(this.name);
        }
    };
    hero.run();
    //创建数组里面装了三个对象
    let arr=[{name:"悟空",age:500},{name:"八戒",age:300},{name:"沙僧",age:200}];
    for (let i = 0; i <arr.length ; i++) {
        let h  =arr[i];
        alert(h.name+":"+h.age);
    }
</script>

</body>
</html>